{% extends 'base.html' %} 
{% block content %}
    <div class="column">
        <form method="post" action="{{ url_for('index') }}">
            <div class="form-group">
                <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
                <label class="form-label" for="url">
                        Ссылка
                </label>
                <input 
                    class="form-input"
                    type="text" 
                    name="url" 
                    id="url" 
                    placeholder="https://длинная-длинная-ссылка.ru" 
                    value="{{ request.form.get('url', '') }}" 
                    autofocus>
            </div>
            <div class="form-group">
                <button 
                    class="btn btn-primary" 
                    type="submit" 
                    name="action">
                    Сократить
                </button>
            </div>
        </form>
    </div>
    <br> 
    {% if shortcuts %}
    <a href="{{ url_for('clear') }}" class="btn btn-link">Очистить</a> <!-- TODO set visibility clear button-->
    <div class="column">
        <table class="table">
            <head>
                <tr>
                    <th>Ярлык</th>
                    <th>QR-код</th>
                    <th>Создан</th>
                </tr>
            </head>
            <tbody>
                {% for shortcut in shortcuts %}
                    <tr class="active">
                        <th>
                            <a href="{{ url_for('redirect_url', shortcut_id=shortcut.shortcut_id, _external=True) }}" target="_blank" role="button">
                                {{ url_for('redirect_url', shortcut_id=shortcut.shortcut_id, _external=True) }}
                            </a>
                        </th>
                        <th>
                            <a href="{{ url_for('get_qr', shortcut_id=shortcut.shortcut_id, _external=True) }}" target="_blank" role="button">
                                <i class="icon icon-apps"></i>
                            </a>
                        </th>
                        <th>
                            {{ shortcut.created | datetime }}
                        </th>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
    <div class="column col-3 p-centered">
        {% include '_pagination.html' %}
    </div>
    {% endif %}
    <script src="{{ url_for('static', filename='js/checkboxhide.js') }}"></script>
{% endblock %}